{extend name="public/base"}

{block name="style"}
<link rel="stylesheet" href="__STATIC__/admin/css/news.css" media="all" />
{/block}


{block name="main"}
<body class="childrenBody">
<div class="layui-form news_list">
    <table class="layui-table">
        <colgroup>
            <col width="50">
            <col>
            <col width="9%">
            <col width="9%">
            <col width="9%">
            <col width="9%">
            <col width="9%">
            <col width="15%">
            <col width="15%">
        </colgroup>
        <thead>
        <tr>
            <th><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose" id="allChoose"></th>
            <th style="text-align:left;">产品名称</th>
            <th>图片</th>
            <th>价格</th>
            <th>店铺</th>
            <th>数量</th>
            <th>描述</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody class="news_content">
            {volist name="data" id="vo"}
            <tr>
                <td><input type="checkbox" name="" lay-skin="primary" lay-filter="choose"></td>
                <td style="text-align:left;">{$vo.product.name}</td>
                <td>
                    <img style="max-width: 120px; max-height: 120px;" src="{$vo.product.thumb|get_img_url}" />
                </td>
                <td>{$vo.product.price}</td>
                <td>{$vo.shop.name}</td>
                <td>{$vo.num}</td>
                <td>{$vo.msg}</td>
                <td>
                    {eq name="vo.status" value="1"}
                    <a href="javascript:" data-url="{:url('create_rq_code', ['id' => $vo['id']])}" class="layui-btn layui-btn-mini create_rq_code">生成二维码</a>
                    {/eq}
                    {eq name="vo.status" value="2"}
                    <a href="{:url('rq_code_list', ['id' => $vo['id']])}" target="_blank" class="layui-btn layui-btn-mini layui-btn-normal">二维码管理</a>
                    {/eq}
                </td>
            </tr>
            {/volist}
        </tbody>
    </table>
</div>
<div id="page"></div>
{/block}

{block name="javascript"}
<script>
    layui.config({
        base : "js/"
    }).use(['form','layer','jquery', 'laydate'],function() {
        var layer = parent.layer === undefined ? layui.layer : parent.layer, $ = layui.jquery;

        $(".create_rq_code").click(function () {
            //弹出loading
            var submit_layer = top.layer.msg('正在努力生成，请稍候',{icon: 16,time:false,shade:0.8});
            $.get($(this).data('url'), function (msg) {
                top.layer.close(submit_layer);
                layer.close(submit_layer);
                if (msg.code == 1) {
                    layer.msg("生成成功！");
                    window.location.reload();
                }
            });
        });
    });
</script>
{/block}